package sphere.view;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import sphere.controler.SphereControler;

public class SphereWindow extends Frame implements ActionListener {
	
		/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		Label Labelradius,Labelsurface,Labelvolume ;
		TextField Txtradius,Txtsurface,Txtvolume ;
		Panel p;
		private SphereControler c;
		public SphereWindow(String title, SphereControler c)
		{
			super(title);
			this.c =c;
			this.c.setView(this);
			setLayout ( new FlowLayout(FlowLayout.LEFT));
			p =new Panel();
			p.setLayout (new GridLayout(3,2));
			
			Labelradius= new Label("Radius");
			Labelsurface= new Label("Surface");
			Labelvolume= new Label("Volume");
			
			Txtradius = new TextField(20);
			Txtradius.setBackground(Color.yellow);
			Txtsurface = new TextField(20);
			Txtsurface.setEditable(false);
			Txtvolume = new TextField(20);
			Txtvolume.setEditable(false);
			Txtradius.addTextListener(c);
			
			p.add(Labelradius);
			p.add(Txtradius);
			p.add(Labelsurface);
			p.add(Txtsurface);
			p.add(Labelvolume);
			p.add(Txtvolume);
			add(p);
			
			this.pack();
			this.setVisible(true);
			this.setResizable(false);
			
			addWindowListener (new WindowAdapter()
			{
				public void windowClosing (WindowEvent e)
				{
					System.exit(0);
				}
			});
		}

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			
		}
		
		
		
		 public void SetSurface(double surface)
	        {
	                this.Txtsurface.setText(String.valueOf(surface));
	        }

	        public void SetVolume(double volume)
	        {
	                this.Txtvolume.setText(String.valueOf(volume));
	        }
}
